<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.tjtt.common.utils.DateUtilsAll"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String mainid = request.getParameter("mainid");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html>
  <head>
     <base target="_self"/>
	<%@ include file="../jslib/jquerylib.jsp" %> 
	<link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js"  defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css" />
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 			
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: auto;
		}  	
		.formTableNew textarea{border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>	
	<script type="text/javascript">
	var api = frameElement.api, W = api.opener;
    var stateValue="";
		$(document).ready(function(){
		
			var appid="${apply.id }";
					$("#gridTable").jqGrid({
						url:'<%=request.getContextPath() %>/applyAction!queryEquList.action?flag=0&appid='+appid,
						datatype: "json",
						height: 250,
						width: 710, 
						autowidth: true, 
						colNames:['ID','设备名称','设备编号','预计使用年限','购进日期','固定资产编号','单位','原值','监管期起始日期','监管期结束日期','部门'],
						colModel:[
								{name:'ID',index:'ID', width:60, key:true,hidden:true,hidedlg:true}, 
								{name:'EQUIPMENT_NAME',index:'EQUIPMENT_NAME', width:100},								
								{name:'EQUIPMENT_NO',index:'EQUIPMENT_NO', width:100},
								{name:'EQU_YJSYNX',index:'EQU_YJSYNX', width:110},
								{name:'EQU_GJ_DATE',index:'EQU_GJ_DATE', width:100},
								{name:'EQUIPMENT_GDZCBH',index:'EQUIPMENT_GDZCBH', width:50},
								{name:'EQUIPMENT_DW',index:'EQUIPMENT_DW', width:110},
								{name:'EQU_YZHI',index:'EQU_YZHI', width:110},
								{name:'EQUIPMENT_JGQQSRQ',index:'EQUIPMENT_JGQQSRQ', width:50},
								{name:'EQUIPMENT_JGQJSRQ',index:'EQUIPMENT_JGQJSRQ', width:50},
								{name:'EQU_ORG_NAME',index:'EQU_ORG_NAME', width:50}
						],   
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					loadComplete: function() {
						
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "设备列表"
			});
			   
			var options = {
		  	    url:'<%=request.getContextPath() %>/applyAction!kezhangshenpi.action?steptype='+$("#steptype0").val()+'&taskinfoid='+${taskinfoid},
		  	     beforeSubmit: function() {
		   				return checking();
		    			},
		  	     dataType:'json',
		  	    success: function(data) {
		  	      if(data.result=='success'){
					alert("提交成功");
					api.close();
					W.refreshIt();
		  	      }
		  	    }
		  	   };
			$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 	});
	    	$('#closeBtn').click(function(){
	    		api.close();
				});
		});
	function checking(){
	   		var flag = true;
			var app_bushenpiren = $("#app_bushenpiren").val();
			var app_bushenpiyijian = $("#app_bushenpiyijian").val();
			var app_bushenpidate = $("#app_bushenpidate").val();
			if(app_bushenpiren ==null || app_bushenpiren == "" ){
				alert("审批人不能为空！");
				$("#app_bushenpiren").focus();
	    		return false;
			}
			if(app_bushenpiyijian == null && app_bushenpiyijian == ""){
				alert("审批意见不能为空！");
				$("#app_bushenpiyijian").focus();
	    		return false;
			}
			if(app_bushenpidate ==null || app_bushenpidate == "" ){
				alert("时间不能为空！");
				$("#app_bushenpidate").focus();
	    		return false;
			}
			
		}
		function dahui(){
        var actionUrl = '<%=request.getContextPath()%>/applyAction!tuihuishebei.action'; 
        var param = {
                      "flowname":$("#flowname").val(),
                      "flowid":"${flowid}",
                      "stateid":"${stateid}",
                      "steptypeback":$("#steptypeback0").val(),
                      "taskinfoid":"${taskinfoid}",
                      "id":$("#id").val()
            };
    	$.ajax({  
			        url : actionUrl,  
			        type : "post", 
			        data : param,  
			        dataType : "json",  
			        cache : false,  
			 error : function(textStatus, errorThrown) {  
			        alert("系统ajax交互错误: " + textStatus.value);  
		    },  
		    success : function(data, textStatus) {
		        if(data.ajaxResult=='success'){ 
		        //      window.returnValue = returnValue;     
				      alert("打回成功");
				      W.reload();
					  api.close();
                   }else{
                       alert("处理失败!");
                       W.reload();
                   }
		    }    
			});
    }
	</script>
	
	
  </head>
  
  <body>
  		<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
        <input type="hidden" name="flowid" id="flowid" value="${flowid}">
     	<input type="hidden" name="stateid" id="stateid" value="${stateid}">
     	${steptcontent}
     	${steptcontentback}
  		<input type="hidden" readonly="readonly" id="appid" name="appid" value="${apply.id }"/>
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew" style="padding-top: 20px">
  			 <tr>
			  <td align="right" style="width: 80px">流程名称:</td>
     		<td align="left">
     		<input type="text" id="flowname" name="flowname" maxlength="50" value="${flowname}" style="border: 1px solid #999;padding: 5px;width:250px;"/>
     		<td align="right">申请原因:</td>
  			  <td align="left" style="width: 80px">
  			    <input  type="text"  id="app_reason"  maxlength="50" name="app_reason" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${apply.app_reason }" />
  			  </td>
  			</tr>
 			<tr>
  			  <td align="right" style="width: 80px">申请人:</td>
  			  <td align="left">
  			    <input  type="text"  id="app_person"  maxlength="50" name="app_person" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${apply.app_person }" />
  			  </td>
  			  <td align="right" style="width: 80px">申请时间：</td>
  			  <td align="left">
  			    <input  type="text"  id="app_date"  maxlength="50" name="app_date" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="${apply.app_date }" />
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right" style="width: 80px">审批人:</td>
  			  <td align="left">
  			    <input  type="text"  id="app_bushenpiren"  maxlength="50" name="app_bushenpiren" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="<%=session.getAttribute("username") %>" />
  			    <img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			   <td align="right" style="width: 80px">审批时间：</td>
  			  <td align="left">
  			    <input  type="text"  id="app_bushenpidate"  maxlength="50" name="app_bushenpidate" onClick="WdatePicker({maxDate:new Date()})" style="border: 1px solid #999;padding: 5px;width: 250px;"  value="<%=DateUtilsAll.dateToStringShort(new Date()) %>" />
  			    <img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			</tr>
  			<tr>
  			   <td colspan="2" align="left" style="width: 150px">申请（附件）原因：</td>
  			  <td colspan="2">
  			  	<jsp:include page="../fileupload/attachment.jsp?id=${apply.id }&column=1&show=y" ></jsp:include>
  			  </td>
  			</tr>
  			<tr>
  				<td align="right" style="width: 80px">审批意见：</td>
	  			   <td colspan="3">
			    	<div class="div">
						<textarea rows="5" cols="100" id="app_bushenpiyijian" name="app_bushenpiyijian" style="width: 750px;"></textarea>
						<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
					</div>	
			    </td>
  			</tr>
            <tr>
                <td colspan="4">
                <div title='设备列表' style='padding:5px'>
                    <table id="gridTable"></table>
                    <div id="gridPager"></div>
                    </div>
                </td>
            </tr>
            <tr>   
			<td align="center" colspan="4">
		    	<input id="saveBtn" type="button" value="提 交"  class="form_bt_orange" />
		    	<input type="button" id="backBtn" value="退回" onclick="dahui()" class="form_bt_orange" />
		    	<input type="button" id="closeBtn" value="取 消" class="form_bt_orange" />
		    </td>
		  </tr>
		</table>
	<!--表单结束-->
	</form>
  </body>
</html>
